/*
 * (c) 2019
 * <tanghaifeng-gz@loongson.cn> <pengren.mcu@qq.com>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 *
 */

#include <common.h>
#include <asm/io.h>

#include <mach/ls2k.h>

void _machine_restart(void)
{
	__raw_writel(0x1, LS2X_ACPI_REG(RST_CTR));

	while (1)
		;
}

int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	__raw_writel(0xffffffff, LS2X_ACPI_REG(PM1_STS));
	__raw_writel(0x3c00, LS2X_ACPI_REG(PM1_CTR));

	while(1);

	return 0;
}

void _machine_poweroff(void)
{
	do_poweroff(NULL, 0, 0, NULL);
}
